import Taro, { Component } from '@tarojs/taro'
import { View, Text, Image, ScrollView, Block } from '@tarojs/components'
// import { LiPrice } from '../../../components'
import './index.scss'

export default class SelectGoods extends Component {
	constructor(props) {
		super(props)
		this.state = {
			// itemData: ''
			itemData: [
				{id:0,keyword: '心水好物', price: 300, sales_price: 1.8, transparentPic: 'https://pop.nosdn.127.net/8dfad5ca-3b1b-430d-8170-87b8d9c44909?imageView&thumbnail=188x0&quality=85'},
				{id:1,keyword: '心水好物', price: 300, sales_price: 1.8, transparentPic: 'https://pop.nosdn.127.net/8dfad5ca-3b1b-430d-8170-87b8d9c44909?imageView&thumbnail=188x0&quality=85'},
				{id:2,keyword: '心水好物', price: 300, sales_price: 1.8, transparentPic: 'https://pop.nosdn.127.net/8dfad5ca-3b1b-430d-8170-87b8d9c44909?imageView&thumbnail=188x0&quality=85'},
				{id:3,keyword: '心水好物', price: 300, sales_price: 1.8, transparentPic: 'https://pop.nosdn.127.net/8dfad5ca-3b1b-430d-8170-87b8d9c44909?imageView&thumbnail=188x0&quality=85'},
				{id:4,keyword: '心水好物', price: 300, sales_price: 1.8, transparentPic: 'https://pop.nosdn.127.net/8dfad5ca-3b1b-430d-8170-87b8d9c44909?imageView&thumbnail=188x0&quality=85'}

			]
		}
	}
	componentWillMount() {
		// this._getGoodThings()
	}
	_toGoods = (ids) => {

	}
	// 跳转webView
	_onWebView = (item) => {
		// Tong.toWebView(`/NiceGoods?hid=${item.id}`)
	}

	render() {
		const { itemData } = this.state
		return (
			<Block>
				{itemData && <View className='good-things'>
						<View className='good-things-box'>
							<View className='good-things-box-top'>
								<View className='top-left'>
									<Image className='top-left-img' src={itemData.topicLogo}></Image>
									<View className='top-left-title'>用心甄选超值优惠</View>
								</View>
								<View className='top-right' onClick={ () => this._onWebView(itemData)}>查看更多</View>
							</View>

							<View className='good-things-box-product'>
								<ScrollView className='good-things-box-product-scroll' scrollX>
									<View className="good-things-box-product-scroll-list">
										{itemData.length && itemData.map((list,index) => <View className='product-list' key={list + index}>
											<View className='product-list-top' onClick={ () => this._toGoods(ids)}>
												<Image className='product-list-top-img' src={list.transparentPic}></Image>
												<View className='product-list-top-text'>
													<Image className='product-list-top-text-img' src='https://img.gojoy.cn/h5/assets/home/sale-bg@2x.png'></Image>
													<Text className='text'>{parseInt((list.sales_price / list.price) * 100)}折</Text>
												</View>
											</View>
											<View className='product-list-info'>
												<LiPrice money={list.sales_price} fontSize={Taro.pxTransform(28)} disPlay='block' color='#222'></LiPrice>
												<View className='marke-price'><LiPrice money={list.price} disabled={true} disPlay='block'></LiPrice></View>
											</View>
										</View>)}
									</View>
								</ScrollView>
							</View>

						</View>
				</View >}
			</Block>
		)
	}
}